prompt support for value type number #12927
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Permit to support x-prompt for a schematic parameter definition if its type is set to number.
Previously, if used with type 'number', the prompt was trap in a loop as input never was considered correct.
The part on the cli will also need to be reproduced on schematics-cli after #12814.
Related to #12163.
Root causes
angular-devkit/core & ajv
Type number wasn't set, and the value wasn't converted to a number if needed in the prompt validator.
angular-devkit/cli & inquirer
Inquirer doesn't convert it result to a number even if definition type is set to 'number' following SBoudrias/Inquirer.js#663
Reproduction steps
You can reproduce the previous behavior by using the @angular-buddies/prettier@1.0.0-alpha.2:prettier-config schematic.
https://github.com/angular-buddies/angular-buddies/blob/v1.0.0-alpha.2/packages/prettier/src/config/schema.json#L14-L19